package com.p2p.auth.controller;

import org.springframework.stereotype.Component;

import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by Antinomy on 16/10/13.
 */

@Component
public class Routes {

    //前端手机
    public static final String APP = "app";
    //后台CRM
    public static final String CRM = "crm";
    //后台CRM
    public static final String INSIDE = "inside";



    private Map<String, String> paths = new ConcurrentHashMap<>();


    public Routes() throws IllegalAccessException {
        Field[] fields = this.getClass().getFields();
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            paths.put(field.getName(), (String) field.get(this));
        }
    }

    public String path(String key) {
        return paths.get(key);
    }

    public static final String HTTP_METHOD_GET = "GET";
    public static final String HTTP_METHOD_POST = "POST";

    public static final String API = "/api/**";



    public static final String FLASHVIEW_PC_LIST = "/api/facade/fashview/pc";
    public static final String FLASHVIEW_PC_PROD_LIST = "/api/facade/fashview/pc/product";
    public static final String COMPANY_DEVELOPMENT_LIST = "/api/facade/company/development";
    public static final String COMPANY_GLORIES_LIST = "/api/facade/company/glories";
    public static final String COMPANY_LEADER_LIST = "/api/facade/company/leader";
    public static final String COMPANY_TEAM_LIST = "/api/facade/company/team";
    public static final String COMPANY_JOBS_LIST = "/api/facade/company/jobs";
    public static final String COMPANY_WEEKLY_VIEW_LIST = "/api/facade/company/weeklyView";

    public static final String UPLOAD = "/api/upload";
    public static final String UPLOAD_CONTRACT = "/api/upload/contract";



    /* Open API */
    public static final String API_MERCHANT_GET_ACCOUNT_BY_MOBILE = "/api/merchant/getAccountByMobile";

    /* BackEnd */
    public static final String MERCHANT_BACKEND_CREATE = "/api/merchant/backend/create";
    public static final String API_MERCHANT_BACKEND_CHANGE_FEATURE_TOGGLES = "/api/merchant/backend/changeFeatureToggles";

    /* FrontEnd */
    public static final String API_MERCHANT_FRONTEND_HUAKANGYUN_INSURANCE = "/api/merchant/frontend/huakangyun/insurance";
    public static final String API_MERCHANT_FRONTEND_APP_FEATURE_TOGGLES = "/api/merchant/frontend/appFeatureToggles";
    public static final String API_GESTURE_CIPHER_GETPUSHMESSAGE = "/api/userinfo/getPushMessage";
    public static final String API_GESTURE_CIPHER_GETCIPHERSTATE= "/api/userinfo/getCipherState";
    public static final String API_GESTURE_CIPHER_SAVEGESTURECIPHER = "/api/userinfo/saveGestureCipher";
    public static final String API_GESTURE_CIPHER_MODIFYGESTURECIPHER = "/api/userinfo/modifyGestureCipher";
    public static final String API_GESTURE_CIPHER_SWITCHGESTURECIPHERSTATE = "/api/userinfo/switchGestureCipherState";
    public static final String API_GESTURE_CIPHER_CLEANGESTURECIPHER = "/api/userinfo/cleanGestureCipher";
    public static final String API_GESTURE_CIPHER_FORGETGESTURECIPHER = "/api/userinfo/forgetGestureCipher";



    // *************文章*****************
    /**
     * 前端App
     */
    public static final String APP_ARTICLE_DETAIL =  Routes.APP + "/article/{uuid}";
    public static final String APP_ARTICLE_TYPE_LIST =  Routes.APP+ "/article/type/{type}";


    /**
     * 后台CRM
     */
    public static final String CRM_ARTICLE =  Routes.CRM + "/article";
    public static final String CRM_ARTICLE_UPDATE =  Routes.CRM + "/article/{id}";
    public static final String CRM_ARTICLE_DETAIL =  Routes.CRM + "/article/{uuid}";
    public static final String CRM_ARTICLE_DETAIL_UUID =  Routes.CRM + "/article/uuid/{uuid}";
    public static final String CRM_ARTICLE_TYPE_LIST =  Routes.CRM + "/article/type/{type}";
    public static final String CRM_ARTICLE_TOP_LIST =  Routes.CRM +"/article/top/{type}";
    public static final String CRM_ARTICLE_TYPE_LIST_ALL =  Routes.CRM + "/article/type/{type}/all";
    public static final String CRM_ARTICLE_LIST_ALL =  Routes.CRM + "/article/list/all";
    public static final String CRM_ARTICLE_UUID_CHANGE_ON_TOP =Routes.CRM +  "/article/{uuid}/changeOnTop";
    public static final String CRM_ARTICLE_UUID_DELETE = Routes.CRM + "/article/{uuid}/delete";


    // ******获取类型*****************
    public static final String CRM_API_OPTION_DETAILS_ARTICLE_TYPE =  Routes.CRM + "/optionDetails/articleType";
    public static final String CRM_API_OPTION_DETAILS_OPERATION_EVENT =  Routes.CRM + "/optionDetails/operationEvent";


    // ***********后台图形验证码**********************
    public static final String CRM_CAPTCHA_CODE =  Routes.CRM +  "/captcha/{verifySource}";
    public static final String CRM_CAPTCHA_VERIFICATION = Routes.CRM +  "/captcha/{verifySource}/verifyCode";


    // **********后台操作日志*************
    public static final String CRM_OPERATION_LOGGING =  Routes.CRM +  "/backend/operationLogging";




    // **********后台权限相关*************
    public static final String CRM_AUTH_USER = Routes.CRM + "/auth/user/{mobile}";
    public static final String CRM_AUTH_CHANGE_PWD = Routes.CRM +"/auth/user/{mobile}/pwd";
    public static final String CRM_AUTH_FORGET_PWD = Routes.CRM  + "/auth/user/{mobile}/pwd/forget";



    public static final String CRM_AUTH_MENU = Routes.CRM + "/auth/menu";//读取所有权限菜单
    public static final String CRM_AUTH_MENU_ROLE = Routes.CRM + "/auth/menu/role";//读取角色的权限菜单
    public static final String CRM_AUTH_MENU_ROLE_IDS = Routes.CRM + "/auth/menu/role/ids";//读取角色的权限菜单Id
    public static final String CRM_USER_ASSIGN_ROLE = Routes.CRM + "/userRole/assign";

    public static final String CRM_ROLE_ASSIGN_MENU = Routes.CRM + "/userRole/assignMenus";
    public static final String CRM_USER_ROLE_LIST = Routes.CRM + "/userRole/list";
    public static final String CRM_USER_ROLE_CREATE =Routes.CRM +  "/userRole/create";
    public static final String CRM_USER_ROLE = Routes.CRM + "/userRole/{roleId}";
    public static final String CRM_USER_ROLE_DELETE = Routes.CRM + "/userRole/{roleId}/delete";




    //***********************登陆相关 ****************************
    public static final String APP_LOGIN = Routes.APP + "/login";//前端h5登陆

    public static final String CRM_LOGIN = Routes.CRM + "/login";//后端CRM登陆
    public static final String CRM_CHANGE_PWD = Routes.CRM +"/login/change/{phoneNum}";
    public static final String CRM_FORGET_PWD = Routes.CRM  + "/login/forget/{phoneNum}";






    //***********************用户相关 ****************************
    public static final String APP_USER_ADD = Routes.APP + "/users";//APP添加用户
    public static final String APP_USER_INFO = Routes.APP + "/users/{userId}";//APP获取用户信息
    public static final String APP_USER_INFO_BY_PHONENUM = Routes.APP + "/info/{phoneNum}";//app根据手机号获取用户信息

    //后台使用
    public static final String CRM_USER_ALL = Routes.CRM + "/users";//CRM获取所有用户
    public static final String CRM_USER_UPD = Routes.CRM + "/{userId}/{userName}";//CRM修改用户
    public static final String CRM_USER_EXCEL = Routes.CRM + "/users/excel";
    public static final String CRM_USER_GET_BY_PHONENUM = Routes.CRM + "/users/getByPhoneNum";
    public static final String CRM_USER_GET_BY_USERID = Routes.CRM + "/users/getByUserId";

    //微服务之间使用
    public static final String INSIDE_USER_ID_BY_PHONENUM = Routes.INSIDE + "/userId/{phoneNum}"; //INSIDE根据手机号获取用户id
    public static final String INSIDE_USER_NAME_BY_PHONENUM = Routes.INSIDE + "/realName/getByPhoneNum";//INSIDE根据手机号获取用户名称
    public static final String INSIDE_USER_GET_MSG_BY_PHONENUM = Routes.INSIDE + "/userMsg/getByPhoneNum";//INSIDE根据手机号获取用户信息
    public static final String INSIDE_USER_GET_MSG_BY_USERID = Routes.INSIDE + "/userMsg/getByUserId";//INSIDE根据userId获取用户信息


    //***********************后台访客相关 ****************************
    //后台使用
    public static final String CRM_VISITOR_LOGIN = Routes.CRM + "/visitor/login";//后端CRM登陆
    public static final String CRM_VISITOR_ADD = Routes.CRM + "/visitor";//CRM获取所有用户
    public static final String CRM_VISITOR_ALL = Routes.CRM + "/visitors";//CRM获取所有用户
    public static final String CRM_VISITOR_UPD = Routes.CRM + "/visitors/update";//CRM修改用户
    public static final String CRM_VISITOR_INIT_PWD = Routes.CRM + "/visitors/initPwd/{userId}";//CRM修改用户



    /**
     * 后段CRM发送短信
     */
    public static final String SMS_GET_TOKEN = "/sms/getToken";
    public static final String SMS_SEND_VERIFICATION_CODE = "/sms/send/verificationCode";
    public static final String SMS_VALIDATE_CODE = "/sms/validateCode";
    public static final String SMS_SEND_TEMPLATE_MSG = "/sms/send/templateMsg";



    /**
     * 微服务之间专用
     */
    public static final String INSIDE_RETAILERS_GET_MSG_BY_RETAILERID = Routes.INSIDE +   "/retailers/getMsgByRetailerId";
    public static final String INSIDE_RETAILERS_GET_MSG_BY_RETAILERNO = Routes.INSIDE +   "/retailers/getMsgByRetailerNo";



}
